package com.capgemini.diabeo;

import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

import com.capgemini.diabeo.settings.SettingsActivity;

public class MealChoice extends Activity {

	public static String mealChoice;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_meal_choice);

		ActionBar actionBar = getActionBar();
		actionBar.setDisplayHomeAsUpEnabled(true);

		Button btn_matin = (Button) findViewById(R.id.breakfastButton);
		Button btn_midi = (Button) findViewById(R.id.lunchTimeButton);
		Button btn_soir = (Button) findViewById(R.id.dinnerButton);

		btn_matin.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				mealChoice = "matin";
				Toast.makeText(getApplicationContext(), "Matin",
						Toast.LENGTH_LONG).show();
				// Rajouter dans une table qu'on a s�lectionn� le matin
				Intent i = new Intent(getApplicationContext(),
						AddDishListActivity.class);
				startActivity(i);
			}
		});

		btn_midi.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				mealChoice = "midi";
				Toast.makeText(getApplicationContext(), "Midi",
						Toast.LENGTH_LONG).show();
				Intent i = new Intent(getApplicationContext(),
						AddDishListActivity.class);
				startActivity(i);
			}
		});

		btn_soir.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				mealChoice = "soir";
				Toast.makeText(getApplicationContext(), "Soir",
						Toast.LENGTH_LONG).show();
				Intent i = new Intent(getApplicationContext(),
						AddDishListActivity.class);
				startActivity(i);
			}
		});

		// insertEntrees();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case android.R.id.home:
			// This ID represents the Home or Up button. In the case of this
			// activity, the Up button is shown. Use NavUtils to allow users
			// to navigate up one level in the application structure. For
			// more details, see the Navigation pattern on Android Design:
			//
			// http://developer.android.com/design/patterns/navigation.html#up-vs-back
			//
			NavUtils.navigateUpTo(this, new Intent(this,
					AddDishListActivity.class));
			return true;
		case R.id.action_settings:
			Intent i = new Intent(this, SettingsActivity.class);
			startActivity(i);
			break;
		default:
			break;
		}

		return true;
	}

	/*
	 * public void insertEntrees() {
	 * 
	 * SQLiteDatabase db = dbOpenHelper.getWritableDatabase(); ContentValues
	 * values = new ContentValues();
	 * values.put(AlimentsEntry.COLUMN_NAME_CATEGORIE, "Entr�es");
	 * values.put(AlimentsEntry.COLUMN_NAME_NOM, "Crudit� vinaigrette");
	 * values.put(AlimentsEntry.COLUMN_NAME_PART, "1");
	 * values.put(AlimentsEntry.COLUMN_NAME_QUANTITE, "100");
	 * values.put(AlimentsEntry.COLUMN_NAME_GLUCIDE, "5");
	 * values.put(AlimentsEntry.COLUMN_NAME_IG, "1");
	 * values.put(AlimentsEntry.COLUMN_NAME_LIPIDE, "1");
	 * 
	 * db.insert( AlimentsEntry.TABLE_NAME, null, values);
	 * 
	 * }
	 */

}
